#include <bits/stdc++.h>
using namespace std;
int n[21],m[21],l[21],v1[21],t,d[21][10001],v2[21][10001],a[21][10001],p[21][10001];
int sor(int o){
    int an=-1;
     for(int i=1;i<=m[o];i++){
        if (p[o][i]>an){
            an=p[o][i];
        }
     }
     return an;

     }
int main (){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int i=1;i<=t;i++){
        cin>>n[i]>>m[i]>>l[i]>>v1[i];
        for (int j=1;j<=n[i];j++){
            cin>>d[i][j]>>v2[i][j]>>a[i][j];
        }
        for (int j=1;j<=m[i];j++){
            cin>>p[i][j];
        }
    }
    int ans[21];
    for (int i=1;i<=21;i++){
        ans[i]=0;
    }
    for (int i=1;i<=t;i++){
            int y=sor(i);
        for(int j=1;j<=n[i];j++){
            if ((v2[i][j]*v2[i][j]+2*a[i][j]*(y-d[i][j]))>v1[i]*v1[i]&&d[i][j]<=y){
                ans[i]++;
            }
        }


    }
    for (int i=1;i<=t;i++){
        cout<<ans[i];
        printf(" ");
        cout<<m[i]-1;
        cout<<endl;
    }
    return 0;
}
